from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime, date
from decimal import Decimal
from app.models.contract import ContractStatus

class ContractBase(BaseModel):
    customer_id: int
    contract_number: str = Field(..., max_length=50)
    contract_date: date
    contract_amount: Decimal
    notes: Optional[str] = None

class ContractCreate(ContractBase):
    file_url: Optional[str] = None
    uploaded_by: Optional[str] = None

class ContractUpdate(BaseModel):
    contract_date: Optional[date] = None
    contract_amount: Optional[Decimal] = None
    file_url: Optional[str] = None
    status: Optional[ContractStatus] = None
    notes: Optional[str] = None

class ContractResponse(ContractBase):
    id: int
    file_url: Optional[str] = None
    status: ContractStatus
    uploaded_by: Optional[str] = None
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True

